package org.vincen.springapp.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.vincen.springapp.domain.diogenes.User;
import org.vincen.springapp.service.diogenes.UserService;

@Controller
public class UserController {

	final Logger logger = LoggerFactory.getLogger(UserController.class);
	@Autowired
	private UserService userService;
	
	@RequestMapping(value="/user")
	public void user(){
		
	}
	
//	@RequestMapping(value="/user/list", method=RequestMethod.GET, produces="text/xml")
	@RequestMapping(value="/user/list", method=RequestMethod.GET, produces="application/json")
	public @ResponseBody User findAllUsers(){
		return userService.findUsers().get(0);
//		List<User> list = userService.findUsers();
//		User user = list.get(0);
//		StringBuilder builder = new StringBuilder();
//		builder.append(user.getUserId());
//		builder.append(" ");
//		builder.append(user.getUsername());
//		builder.append(" ");
//		builder.append(user.getPassword());
//		builder.append(" ");
//		builder.append(user.getRealName());
//		builder.append(" ");
//		builder.append(user.getEmail());
//		builder.append(" ");
//		builder.append(user.getPhone1());
//		builder.append(" ");
//		builder.append(user.getPhone2());
//		builder.append(" ");
//		return builder.toString();
	}
}
